<route type="page" lang="json5">
{
  layout: 'default',
  style: {
    navigationBarTitleText: '权限demo'
  },
  name: 'authDemo'
}
</route>

<template>
  <view class="min-h-100vh">
    <view class="py-24rpx flex justify-center">
      <wd-button @click="handelChangeUserPermission">点击切换用户权限</wd-button>
    </view>
    <wd-cell title="operation:user:create权限" v-perms="['operation:user:create']"></wd-cell>
    <wd-cell title="operation:user:update权限" v-perms="['operation:user:update']"></wd-cell>
  </view>
</template>

<script lang="ts" setup>
/* ------------------------ 导入 与 引用 ----------------------------------- */
import { useUserStore } from '@/store';
const { setUserBtnPermission } = useUserStore();
/* ------------------------ 函数 与 方法 ----------------------------------- */

let count = 1;
const handelChangeUserPermission = () => {
  if (count === 1) {
    setUserBtnPermission(['operation:user:create']);
    count = 2;
  } else if (count === 2) {
    setUserBtnPermission(['operation:user:create', 'operation:user:update']);
    count = 3;
  } else {
    setUserBtnPermission(['operation:user:update']);
    count = 1;
  }
};

/* ------------------------- 生命周期 -------------------------------------- */
</script>

<style lang="scss" scoped></style>
